import React from 'react';

import Header from '../common/Header';
import CKTable from '../components/CKTable';
import CKModal from '../components/CKModal';
import CKPages from '../components/CKPages';

import moment from 'moment';

import Fetch from '../common/Fetch';

class ParLinkManageEdit extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            type:this.props.params.id?'edit':'add',
           
        };
    }

    componentDidMount() {
     
    }

    render() {
        return (
            <div className="content">
                <Header title={this.state.type==='edit' ? '修改友情链接':'添加友情链接'}/>
                
                <CKModal ref={(c)=> {
                    this.modal = c
                }}/>
            </div>
        )
    }

    renderTable() {
        return (
            <div>
                <CKTable ref="table" data={this.state.data} select={false}
                         onRefresh={()=>this.loadCategory(1)}>
                    <CKTable.Header text="ID" field="ParLinkManageEdit_id"/>
                    <CKTable.Header text="标签名称" field="ParLinkManageEdit_name"/>
                    <CKTable.Header text="标签数量" field="ParLinkManageEdit_num"/>
                    <CKTable.Header text="创建时间" field="ParLinkManageEdit_created_date" onFormat={(val)=> {
                        return moment.unix(val).format('YYYY-MM-DD HH:mm:ss')
                    }}/>
                </CKTable>
                <CKPages current={this.state.currentPage}
                         number={this.state.pageNum}
                         count={this.state.dataCount}
                         onSelect={(page)=> {
                             this.loadCategory(page)
                         }}/>
            </div>
        );
    }

    renderNotData() {
        return (
            <div style={{textAlign: 'center', fontSize: '24px', paddingTop: '200px'}}>
                没有数据
            </div>
        );
    }
}
ParLinkManageEdit.contextTypes = {
    router: React.PropTypes.object
};
export default ParLinkManageEdit;